local yushou = fk.CreateSkill {
  name = "th_yushou",
  max_phase_use_time = 1,
}

yushou:addEffect(fk.CardUseFinished, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(yushou.name) and target and target ~= player and
    data.card and data.card.trueName == "slash" then
      return #Card:getIdList(data.card) ~= 0 and table.every(Card:getIdList(data.card), function(id) return player.room:getCardArea(id) == Card.Processing end)
    end
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(target, {
      skill_name = yushou.name,
      prompt = "#th_yushou-invoke:" .. player.id
    })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:obtainCard(player, Card:getIdList(data.card), true, fk.ReasonJustMove)
    if not player.dead and not target.dead then
      if room:askToSkillInvoke(player, {
        skill_name = yushou.name,
        prompt = "#th_yushou-draw:"..target.id
      }) then
        target:drawCards(1, yushou.name)
        room:addPlayerMark(target, "_th_yushou-turn", 1)
      end
    end
  end,
}, { check_skill_limit = true })

yushou:addEffect("targetmod", {
  name = "#th_yushou_targetmod",
  residue_func = function(self, player, skill, scope, card, to)
    if player:getMark("_th_yushou-turn") > 0 and card and card.trueName == "slash" and scope == Player.HistoryPhase then
      return player:getMark("_th_yushou-turn")
    end
  end
})

Fk:loadTranslationTable{
  ["th_yushou"] = "御狩",
  [":th_yushou"] = "每阶段限一次，其他角色使用【杀】后，其可以将此【杀】交给你，然后你可以令其摸一张牌且其本回合使用【杀】次数上限+1。",

  ["#th_yushou-invoke"] = "御狩：你可以将此【杀】交给 %src，然后其可以令你摸一张牌且你本回合使用【杀】次数上限+1",
  ["#th_yushou-draw"] = "御狩：你可以令 %src 摸一张牌且其本回合使用【杀】次数上限+1",
}

return yushou